<?php
/* @var $this InventoryController */
/* @var $model Inventory */

$this->breadcrumbs=array(
	'Inventories'=>array('index'),
	$model->id,
);


$this->menu=array(

	array('label'=>'Pull Out', 'visible'=>!Yii::app()->user->isGuest, 'url'=>array('/pullOut/create' , 'id'=>$model->id)),
	array('label'=>'Insert', 'visible'=>!Yii::app()->user->isGuest, 'url'=>array('/insert/create' , 'id'=>$model->id)),
	
	array('label'=>'List Inventory', 'url'=>array('index')),
	array('label'=>'Create Inventory', 'url'=>array('create')),
	array('label'=>'Delete Inventory', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
	array('label'=>'Manage Inventory', 'url'=>array('admin')),
);


?>



<h1>Inventory <?php echo $model->id; ?></h1>

<?php


	$sql = "Select * from pull_out";
    $dataReader =  Yii::app()->db->createCommand($sql)->query();
    while(($row = $dataReader->read())!==false) {$pull = $row;}
	
	
?>

<br>
<br>

<?php $this->widget('zii.widgets.CDetailView', array(
	'data'=>$model,
	'attributes'=>array(
	 array('label'=>'Item Code', 'value'=>$model->item->item_code),
		array('label'=>'Item', 'value'=>$model->item->item_desc),
		
		array('label' => 'Stock', 'value' => $model->qty_in_stock.' '. $model->item->unit ),
		'date',
		array('label'=>'User', 'value'=>$model->user->fname .' '. $model->user->lname ),
	),
)); ?>


<?php 
$config = array();
$dataProvider = new CArrayDataProvider($rawData=$model->pullOuts, $config);

?>
<br><br><h2>Pulled Out</h2> <?php
$this->widget('zii.widgets.grid.CGridView', array('dataProvider'=>$dataProvider, 'columns'=>array(
		array('name'=>'Date', 'value'=>'$data->date'),
		array('name' => 'Qty Collected', 'value' => '$data->qty' .' ." " .$data->inventory->item->unit ' ),
		array('name' => 'Project', 'value' => '$data->project->project_name' ),
		array('name' => 'Comment', 'value' => '$data->comment' ),
		array('name' => 'User', 'value' => '$data->user->fname'  .  ' ." " .$data->user->lname'),
	
    )
	
));
?>


<?php 
$config = array();
$dataProvider = new CArrayDataProvider($rawData=$model->inserts, $config);
?>
<br><br><h2>Inserted</h2> <?php
$this->widget('zii.widgets.grid.CGridView', array('dataProvider'=>$dataProvider, 'columns'=>array(
		array('name'=>'Date', 'value'=>'$data->date'),
		array('name' => 'Qty Inserted', 'value' => '$data->qty' .' ." " .$data->inventory->item->unit '  ),
		array('name' => 'Comment', 'value' => '$data->comment' ),
		array('name' => 'User', 'value' => '$data->user->fname'  .  ' ." " .$data->user->lname'),
    )	
));
?>

